﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MockupDesigner.Items;
using System.Windows.Controls;

namespace MockupDesigner.Editors.TextEditors
{
    public class ListBoxEditor : ContentControlContainerEditor
    {
        protected override string[] GetItemSeparators()
        {
            return new string[] { "\r", "\n", "\r\n" };
        }

        protected override IList<ContentControl> GetContentControlsForItems(string[] items)
        {
            IList<ContentControl> result = new List<ContentControl>();
            foreach (string item in items)
            {
                result.Add(new System.Windows.Controls.ListBoxItem() { Content = item });
            }
            return result;
        }

        protected override string GetStringItems()
        {
            StringBuilder sb = new StringBuilder();
            foreach (ContentControl item in this.itemToEdit.ItemsSource)
            {
                sb.AppendLine(item.Content.ToString());
            }
            return sb.ToString();
        }

        public override bool AcceptsReturn
        {
            get { return true; }
        }
    }
}
